package com.travelsupport.ui;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.travelsupport.myobject.CurrencyObj;

public class CurrencyAdapter extends BaseAdapter
{  
	
	LayoutInflater inflater;
	List<CurrencyObj> items;
	
    public CurrencyAdapter(Activity context, List<CurrencyObj> items) {  
        super();
		
        this.items = items;
        this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    
    @Override  
    public int getCount() {  
        // TODO Auto-generated method stub  
        return items.size();  
    }  
  
    @Override  
    public Object getItem(int position) {  
        // TODO Auto-generated method stub  
        return null;  
    }  
  
    @Override  
    public long getItemId(int position) {  
        // TODO Auto-generated method stub  
        return 0;  
    }
      
    @Override  
    public View getView(final int position, View convertView, ViewGroup parent) {  
        // TODO Auto-generated method stub  

    	CurrencyObj item = items.get(position);
    	View vi=convertView;
        
        if(convertView==null)
            vi = inflater.inflate(R.layout.currency_list_row, null);
            
        ImageView imgCurrency = (ImageView) vi.findViewById(R.id.icon_currency);
        TextView txtCurrency = (TextView) vi.findViewById(R.id.txtCurrency); 
        
        imgCurrency.setImageResource(item.item_currency);
        txtCurrency.setText(item.currency.toString());
        
        return vi;  
    }
}